package structural_pattern.facade;

public class SmartAppliancesFacade {
    // 聚合电器的对象
    private Light light;
    private TV tv;
    private AirCondition airCondition;

    SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }

    // 提供统一的接口
    public void say(String message) {
        if(message.contains("打开")){
            on();
        } else if(message.contains("关闭")){
            off();
        } else {
            System.out.println("请重说");
        }
    }

    private void on() {
        light.on();
        tv.playTV();
        airCondition.on();
    }
    private void off() {
        light.off();
        tv.stopTV();
        airCondition.off();
    }
}
